{#include file="top.php"#}
<script type="text/javascript">
    function showpop(text){
        $("#fullbg").fadeIn();
        $("#dialog1").fadeOut('slow');
        $("#dialog").fadeOut('slow');
        showLB('#dialog_popup',0);
        $("#popupText").text(text);
    }
    function plikes(sec,sid){
        $.getJSON("product.php?action=ajax&t=3",{sec:sec,sid:sid},function(data){
            if(parseInt(data.recode)==1){
                $('#'+sec+'_likes_'+sid).html(data.likes);
            }else if(parseInt(data.recode)==2){
                $("#loginText").text("以iMORE帳戶登入");
                $("#login").attr("onClick","login('plikes(\\'"+sec+"\\',"+sid+")')");
                $("#login_type").attr("onClick","fnblogin('plikes(\\'"+sec+"\\',"+sid+")')");
                showLB('#dialog',0);
            }else{
                showpop(data.msg);
            }
        });
    }


    function login(func){

        var email = $('#email').val();
        if($.trim(email).length==0){
            showpop("{#$NO_USERNAME#}");
            $('#email').focus();
            return false;
        }
        var password = $('#password').val();
        if($.trim(password).length==0){
            showpop("{#$NO_PASSWORD#}");
            $('#password').focus();
            return false;
        }
        /*
                var captcha = $('#captcha').val();
                if($.trim(captcha).length==0){
                        showpop("{#$ERR_CAPTCHA#}");
                        $('#captcha').focus();
                        return false;
                }
         */

        $.getJSON("member.php?action=ajax_login_imore",{email:email,password:password/*,captcha:captcha*/},function(data){
            if(parseInt(data.ret)==1){
                showpop(data.msg);
            }else if(parseInt(data.ret)==2){
                showpop(data.msg);
                //$('#captcha').attr("src","captcha.php?t="+Math.random());
            }else{closeLB();memberBar();eval(func);}
        });
    }

    function login_fnb(func){
        var email = $('#email').val();
        if($.trim(email).length==0){
            showpop("{#$NO_USERNAME#}");
            $('#email').focus();
            return false;
        }
        var password = $('#password').val();
        if($.trim(password).length==0){
            showpop("{#$NO_PASSWORD#}");
            $('#password').focus();
            return false;
        }
        /*
                var captcha = $('#captcha').val();
                if($.trim(captcha).length==0){
                        showpop("{#$ERR_CAPTCHA#}");
                        $('#captcha').focus();
                        return false;
                }
         */


        $.getJSON("member.php?action=ajax_login_fnb",{email:email,password:password/*,captcha:captcha*/},function(data){
            if(parseInt(data.ret)==1){
                showpop(data.msg);
            }else if(parseInt(data.ret)==2){
                showpop(data.msg);
                //$('#captcha').attr("src","captcha.php?t="+Math.random());
            }else{closeLB();memberBar();eval(func);}
        });
    }

    function fnblogin(func){
        $("#loginText").text("F&amp;B 會員登入 REGISTRATION");
        $("#login").attr("onClick","login_fnb("+func+")");
        $("#login_type_text").text("以 iMORE 登入");
        $("#login_type").attr("onClick","itriallogin("+func+")");
        $("#loginTextName").css("background-position","0 -940px");
        $("#classlogo").attr("class","itrial ir");
    }
    function itriallogin(func){
        $("#loginText").text("iTRIAL 會員登入 REGISTRATION");
        $("#login").attr("onClick","login("+func+")");
        $("#login_type_text").text("以 F&B 登入");
        $("#login_type").attr("onClick","fnblogin("+func+")");
        $("#loginTextName").css("background-position","0 -900px");
        $("#classlogo").attr("class","fabtn ir");
    }

    function showLB(ct,n){
        var sh=$(document).height();
        var sw=$(document).width();
        var st=$(window).scrollTop();
        var ch=$(window).height();
        var cw=$(window).width();
        var tbT=(Number(ch)/3+Number(st))+"px";
        var tbL=(Number(cw)/2)+"px";
        if(n==0){
            $("#fullbg").css({width:sw,height:sh});
            $(ct).css({top:tbT,left:tbL});
            $("#fullbg").fadeTo('slow', 0.4);
            $(ct).fadeIn('slow');
            $(window).scroll(function(){showLB(ct,1)});
            $(window).resize(function(){showLB(ct,1)});
        }else{
            if($("#fullbg").css("display")=="block"){
                $("#fullbg").css({width:sw,height:sh});
                $(ct).css({top:tbT,left:tbL});
            }
        }
    }

    function closeLB(){
        $("#fullbg").fadeOut('slow');
        $('#dialog').fadeOut('slow');
        $('#dialog_popup').fadeOut('slow');

    }

</script>

<style type="text/css">
    #fullbg{
        background-color: #000;
        display:none;
        z-index:90;
        position:absolute;
        left:0px;
        top:0px;
        filter:Alpha(Opacity=30);
        -moz-opacity:0.4;
        opacity: 0.4;
    }
    #dialog {
        z-index: 100;
        display:none;
    }
</style>
<div class="body">
    <div class="main">
        <div class="search_box">
            <form id='form1' name='form1' action='search.php?action=report' method='post'>
                <span class="title">搜尋</span>
                <div class="box">

                    <input type="text" name='find' placeholder="keyword"  value='{#$find#}' />
                </div>
                <a href="javascript:void(0);" class="b" onclick="form1.submit()"><strong>搜尋</strong></a>
            </form>
        </div>
        <div class="tab_b_box">
            <a href="search.php?action=product&find={#$find#}" >邀請</a>
            <a href="search.php?action=report&find={#$find#}" class="curr">報告</a>
            <a href="search.php?action=event&find={#$find#}" >活動事件</a>
            <em class="line"></em>
            <span class="info">共有{#$total#}個 “{#$find#}” 報告結果</span>
        </div>
        <div class="result_box">
            <div class="hybox">
                <div class="ul clearfix">
                    {#foreach  from=$reps item=v key=k#}
                    <div class="b_box b_box_pro_rep {#if $k eq 3#}b_box_pro_rep_1{#/if#}">
                        <div class="bd">
                            <div class="box_hd box_hd_w">
                                <figure class="img_box">
                                    <a href="product.php?action=detail&mtype={#$v.product.member_type#}&pid={#$v.product.id#}">
                                        <img src="{#$v.product.photo#}" />
                                    </a>
                                </figure>
                                <h2 class="title_en">{#$v.product.type_name#}</h2>
                                <h3 class="title_cn">{#$v.product.cname#}</h3>
                                <div class="intro">
                                    <span><sup>好</sup>{#$v.product.good#}</span>
                                    <em>/</em>
                                    <span><sup>一般</sup>{#$v.product.common#}</span>
                                    <em>/</em>
                                    <span><sup>差</sup>{#$v.product.bad#}</span>
                                </div>
                            </div>
                            <div class="box_mid">
                                <p class="que">{#$v.report.title#}</p>
                                <div class="star_box">
                                    <table><tbody><tr>
                                                {#foreach  from=$v.report.category item=v1 key=k1#}
                                                <th>{#$v1.name#}</th>
                                                <td><strong class="star star_{#$v1.value#}">{#$v1.value#}星</strong></td>
                                                {#if $k1 eq 2 || $k1 eq 5 || $k1 eq 8#}</tr><tr>{#/if#}
                                                {#/foreach#}
                                            </tr>
                                        </tbody></table>
                                    <div class="btn_box_r">
                                        <span><a id='report_likes_{#$v.report.id#}'>{#$v.report.likes#}</a>個推介</span>
                                        <a href="javascript:void(0);" onclick="plikes('report',{#$v.report.id#})" class="btn_pink">推介</a>
                                        <a href="javascript:void(0);" onclick='postToFeed{#$v.report.id#}(); return false;' class="btn_fb_share">facebook share</a>
                                        <script>
                                            function postToFeed{#$v.report.id#}() {
                                                // calling the API ...
                                                var obj = {
                                                    method: 'feed',
                                                    //redirect_uri: location.href,
                                                    redirect_uri: 'https://www.imore.hk/',
                                                    link: 'https://developers.facebook.com/docs/reference/dialogs/',
                                                    picture: 'http://www.imore.hk/upload/pickpic/photo/2012/12/21/20121221165502987.jpg',
                                                    name: '{#$v.report.title#}',
                                                    caption: '{#$v.report.title#}',
                                                    description: '{#$v.report.body#}'
                                                };

                                                function callback(response) {
                                                    document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
                                                }
                                                FB.ui(obj, callback);
                                            }
                                        </script>
                                    </div>
                                </div>
                            </div>
                            <div class="box_bot">
                                <p>{#$v.report.body#}<a href="product.php?action=reportDetail&mtype={#$v.product.member_type#}&pid={#$v.product.id#}&rid={#$v.report.id#}" >更多</a></p>
                                <ul class="clearfix">
                                    {#foreach  from=$v.report.content item=v2 key=k2#}
                                    {#if $v2.p && $k2<4#}<li {#if $k2 eq 3#}class="last"{#/if#}><img src="{#$v2.p#}" alt="pic" /></li>{#/if#}
                                    {#/foreach#}
                                </ul>
                            </div>
                        </div>
                    </div>
                    {#/foreach#}

                    <span class="list left_fix">&nbsp;</span>
                </div>
            </div>

        </div>
        {#$pagelist#}
    </div>
    <!-- main-->
    <div class="sidebar">

        {#show_block('b2',1,'','sidebar_ad')#}
        {#show_block('b1',2,'','sidebar_function')#}
        {#show_block('b4',0,'','sidebar_workshop')#}
        {#show_block('b11',0,'','sidebar_new_try sidebar_new b_box')#}
        {#show_block('b5',0,'','sidebar_top3 b_box')#}
        {#show_block('b6',0,'','sidebar_facebook')#}
    </div>
    <!-- sidebar -->

</div><!--body-->
<!--  遮罩層  -->
<div id="fullbg"></div>
<div  class="irpopbox popbox b_box" id="dialog">
    <div class="hd">
        <h2 class="ir ht" id=loginTextName><span id=loginText>iTRIAL 會員登入 REGISTRATION</span></h2>
        <a class="popclose" style="cursor:pointer" onclick="closeLB();">close</a>
    </div>
    <div class="bd">
        <div class="lbox">
            <p>Username</p>
            <input type="text" class="ipt" name="email" id="email">
            <p>PASSWORDS</p>
            <input type="password" class="ipt" name="password" id="password">
            <a class="btn_s btn_s_login" onclick="login()" style="cursor:pointer" id="login"><strong>login</strong></a>
            <ul>
                <li><a href="member.php?action=forgetPassword">忘記密碼</a></li>
                <li><a href="member.php?action=reg&toURL={#$thisUrl#}">註冊新帳號</a></li>
            </ul>
        </div>
        <div class="rbox">
            <div class="lgbox"><em class="hack"></em>
                <a class="fbtn ir" href="member.php?action=login_facebook&toURL={#$thisUrl#}"><strong>以facebook登入</strong></a><span><a class="fb_link" href="member.php?action=login_facebook&toURL={#$thisUrl#}">以facebook登入</a></span>
            </div>
            <div class="lgbox lgbox2" onClick="fnblogin()" id=login_type style="cursor:pointer" ><em class="hack"></em>
                <a class="fabtn ir" id=classlogo><strong>以F&amp;B登入</strong></a><span id=login_type_text  >以F&amp;B登入</span>
            </div>
        </div>
    </div>
</div>
<div style="top:400px;z-index:60;display:none;" class="apopbox popbox b_box" id="dialog_popup">
    <div class="hd">
        <h2 class="ir ht"><span>提示信息 ALERT</span></h2>
        <a class="popclose" onclick="closeLB();" style="cursor:pointer">close</a>            </div>
    <div class="bd">
        <p id="popupText"></p>
        <a class="btn_b btn_s_im_back" href="javascript:void(0);" onclick="closeLB();"><strong>立即返回</strong></a>            </div>
</div>
{#include file="footer.php"#}